<?php
require_once dirname(__DIR__).'/common/common.php';
$pwd=addslashes($_POST['pwd']);
$nickname=addslashes($_POST['nickname']);
$mailbox=addslashes($_POST['mailbox']);

if (!$pwd||!$nickname||!$mailbox)//空字符串表示为false
{
    echo json_encode(array('info'=>'输入为空','code'=>0));
    exit;
}
$sql="SELECT * FROM `register` WHERE nickname='$nickname' ";
$data=mysqli_query($mysql,$sql);
$arr=mysqli_fetch_assoc($data);
mysqli_free_result($data);
if (!empty($arr))
{
    echo json_encode(array('info'=>'已存在','code'=>0));
    exit;
}
/*if ($_SESSION['tt']!=$_POST['txt'])
{
    echo json_encode(array('info'=>'验证码错误','code'=>0));
    exit;
}*/
$sql="INSERT INTO `register`(pwd,nickname,mailbox) VALUES ('$pwd','$nickname','$mailbox')";
$bool=mysqli_query($mysql,$sql);
//echo json_encode(array('info'=>$sql,'code'=>0));
if ($bool)
{
    echo json_encode(array('info'=>'注册成功','code'=>0));
}
